<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //封装一个数字对象，里面有pi，求数组的最大值和最小值

        let myMath = {
            PI: 3.14,
            getMax: function (arr) {
                let max = arr[[0]];
                for (let index in arr) {
                    if (arr[index] > max) {
                        max = arr[index];
                    }
                }
                return max;
            },

        
        getMin: function (arr) {
            let min = arr[0];
            for (let index in arr) {
                if (arr[index] < min) {
                    min = arr[index];
                }
            }
            return min;
        }
        }
        console.log(myMath.PI);
        let arr = [2, 12, 5, 3];
        console.log(myMath.getMax(arr));
        console.log(myMath.getMin(arr));
    </script>
</body>

</html>